package cn.aiyuan.service;

import cn.aiyuan.domain.Metric;
import cn.hutool.core.collection.ListUtil;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wangyuan
 * @date 2021/7/16
 */
@Service
public class CacheTestService {

    @Cacheable(cacheNames = "all#30")
    public List<Metric> getMetric(){
        System.out.println("执行方法...");
        return ListUtil.of(Metric.builder().hostname("hostname").job("job").node("node").instance("instance").build());
    }


    @Cacheable(cacheNames = "metric#30",key = "#instance")
    public Metric getMetricOne(String instance){
        System.out.println("执行方法ONE...");
        return Metric.builder().hostname("hostname").job("job").node("node").instance("instance").build();
    }
}
